{% extends 'base/header.html' %}

{% block title %}
    管理论坛
{% endblock %}



{% block body %}
    <form method="get" class="mb-3">
        <input type="text" name="title" placeholder="标题搜索" class="form-control" value="{{ request.GET.name }}">
        <button type="submit" class="btn btn-primary mt-2">Search</button>
    </form>
    {#    <a href="{% url 'blog:blog_create' %}">创建新博客</a>#}
    <hr>
    <table class="table table-bordered">
        <thead>
        <tr>
            <th>ID</th>
            <th>标题</th>
            <th>分类</th>
            <th>内容</th>
            <th>封面</th>
            <th>发布时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        {% for blog in blogs %}
            <tr>
                <td>{{ blog.id }}</td>
                <td>{{ blog.title }}</td>
                <td>{{ blog.classify }}</td>
                <td>{{ blog.content }}</td>
                <td><img src="{{ blog.cover }}" width="100px" height="100px" alt="我是封面"/></td>
                <td>{{blog.date_time|date:"Y-m-d H:i:s"}}</td>
                <td>
                    <a href="{% url 'blog:blog_update' blog.id %}" class="btn btn-warning btn-sm">编辑</a>
                    <a href="{% url 'blog:blog_delete' blog.id %}" class="btn btn-danger btn-sm">删除</a>
                </td>
            </tr>
        {% endfor %}
        </tbody>
    </table>
    {#    {% for blog in blogs %}#}
    {#        <div class="blog">#}
    {#            <h2>{{ blog.title }}</h2>#}
    {#            <p>分类: {{ blog.classify }}</p>#}
    {#            <p>{{ blog.content|truncatechars:100 }}</p>#}
    {#            <div class="actions">#}
    {#                <a href="{% url 'blog:blog_detail' blog.id %}">查看详情</a>#}
    {#                <a href="{% url 'blog:blog_update' blog.id %}">编辑</a>#}
    {#                <a href="{% url 'blog:blog_delete' blog.id %}">删除</a>#}
    {#            </div>#}
    {#        </div>#}
    {#    {% endfor %}#}

{% endblock %}
